package com.prs.crm.listener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.courser.struts.BaseAction;

import com.prs.crm.context.AccountContext;
import com.prs.crm.context.AppContext;
import com.prs.crm.context.UserLoginStore;
import com.prs.crm.service.exchange.OnlinePersonService;

public class LoginListener extends BaseAction implements HttpSessionListener {
	private OnlinePersonService onlinePersonService;

	public void sessionCreated(HttpSessionEvent se) {
		
		
	}

	public void sessionDestroyed(HttpSessionEvent se) {
      
		try {
			if (se.getSession().getAttribute(AppContext.ACCOUNTCONTEXT_KEY) != null) {
			
				UserLoginStore.removeUser(((AccountContext) se.getSession().getAttribute(AppContext.ACCOUNTCONTEXT_KEY)).currentUser());
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
	}

	public OnlinePersonService getOnlinePersonService() {
		return onlinePersonService;
	}

	public void setOnlinePersonService(OnlinePersonService onlinePersonService) {
		this.onlinePersonService = onlinePersonService;
	}

	
}
